home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Franz PD
/
Franz PD Disk #036 (1990)(Amiga User Group Deutschland e.V.).zip
/
Franz PD Disk #036 (1990)(Amiga User Group Deutschland e.V.).adf
/
SPRITESinACTION
/
Demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-02
|
3KB
|
90 lines
/* Demo fuer Sprites in Action V1.2 */
/* (C) in 1989 by G.A.P */
/* fuer Aztec-C V3.6 */
/* cc Demo.c -s +l */
/* ln Demo.o -lc32 */
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <libraries/dos.h>
#include <graphics/gfxmacros.h>
#include <graphics/sprite.h>
#include <exec/types.h>
#define VP &Screen->ViewPort
struct Screen *Screen;
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct FileName *Fhandle;
USHORT S_Height[1],Anim_Strt[1],Anim_Stop[1],
r[3],g[3],b[3],
Sprites[16][68],num=2,C_Sprites;
struct SimpleSprite sprite={Sprites[0],32};
main()
{
OpenLib(); /* Libs oeffnen */
Screen = IntuitionBase->ActiveScreen;
GetSprite(&sprite,num); /* Sprite 2 aktivieren */
Load_Sprite(); /* Daten laden */
FreeSprite(num); /* Sprite loeschen */
; /* Libs schliessen */
}
OpenLib()
{
if(!(IntuitionBase=(struct IntuitionBase *)
OpenLibrary("intuition.library",0))){
CloseLib();
}
if(!(GfxBase=(struct GfxBase *)
OpenLibrary("graphics.library",0))){
CloseLib();
}
}
CloseLib()
{
if(IntuitionBase) CloseLibrary(IntuitionBase);
if(GfxBase) CloseLibrary(GfxBase);
}
Load_Sprite()
{
USHORT i,j;
Fhandle=Open("Man.dat",MODE_OLDFILE); /* hier Filename der */
if(Fhandle==0) return(); /* Animationsdatei eintragen */
Read(Fhandle,S_Height,2); /* Hoehe lesen */
Read(Fhandle,Anim_Strt,2); /* Startphase l. */
Read(Fhandle,Anim_Stop,2); /* Stopphase l. */
Read(Fhandle,r,6); /* 3 Rot-Anteile l. */
Read(Fhandle,g,6); /* 3 Gruen-A. l. */
Read(Fhandle,b,6); /* 3 Blau-A. l. */
j=Anim_Strt[0];
C_Sprites=Anim_Stop[0]-Anim_Strt[0]; /* Anzahl der Phasen */
for(i=0;i<(C_Sprites+1);i++)
{
Read(Fhandle,Sprites[i],4*S_Height[0]+8); /* Daten lesen */
}
Close(Fhandle);
for(i=0;i<4;i++) SetRGB4(VP,i+21,r[i],g[i],b[i]); /* Farbreg. setzen */
Animation(); /* Animation starten */
}
Animation()
{
USHORT i,x,y;
y=100; /* y-Koordinate */
for(x=0;x<640;x+=2) /* x-Bewegung von 0 bis 640 */
{
MoveSprite(VP,&sprite,x,y);
ChangeSprite(VP,&sprite,Sprites[i]); /* naechste Phase */
i++;
if(i>C_Sprites) i=0;
Delay(3); /* warten */
}
}